package top.xchch.tool.mockito.juejin;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.util.List;

import static org.mockito.Mockito.verify;

/**
 * 减少代码
 * 增强可读性
 * 让verify出错信息更易读, 因为变量名可用来描述标记mock对象
 */
public class MockTest09 {
    @Mock
    List<String> mockedList;

    @Before
    public void initMocks() {
        //必须,否则注解无效
        MockitoAnnotations.initMocks(this);
    }

    @Test
    public void testMock() throws Exception {
        mockedList.add("one");
        verify(mockedList).add("one");
    }
}